package com.monitor.controller.back;

import com.alibaba.fastjson.JSON;
import com.monitor.common.MonitorConstants;
import com.monitor.common.response.CodeMsg;
import com.monitor.common.response.Result;
import com.monitor.controller.BaseController;
import com.monitor.service.LoginService;
import com.monitor.vo.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName LoginController
 * @Package com.kele.controller
 * @Description 登录
 * @Author zhixingbai
 * @Create 2018/9/3011:10
 */
@RestController
@RequestMapping("/back")
public class LoginController extends BaseController {

    @Autowired
    LoginService loginService;

    @RequestMapping("/login")
    public Result login(LoginVo loginInfo){
        logger.info("登录请求:{}",JSON.toJSONString(loginInfo));
        Result result=loginService.login(loginInfo);
        if(result.getStatus()==CodeMsg.SUCCESS){
            setSessionAttr(MonitorConstants.USER_SESSION_KEY,result.getData());
        }
        return result;
    }
}
